package 序列化操作;

import java.io.*;

public class text {
    public static void main(String[] args) {
        Student st1 = new Student("小明","19","123456");
        FileOutputStream fos=null;
        ObjectOutputStream ops = null;

        FileInputStream fis=null;
        ObjectInputStream ois=null;

        try {
            fos=new FileOutputStream("F:\\Java\\项目\\高级Api使用\\src\\序列化操作\\student_1.txt");
            ops = new ObjectOutputStream(fos);



            fis=new FileInputStream("F:\\Java\\项目\\高级Api使用\\src\\序列化操作\\student_1.txt");
            ois = new ObjectInputStream(fis);


            ops.writeObject(st1);

            Student st2 = (Student) ois.readObject();
            System.out.println(st2.getName()+st2.getAge()+st2.getPassword());



        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }catch (IOException e) {
            e.printStackTrace();
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }
}
